<template>

      <el-col :span="24" class="colmargin">
        <el-card class="box-card" style="width:100%;margin:auto; margin-bottom:10px;padding:10px
        ;font-size: 14px; overflow: auto;" v-for="(item,index) in currentPageData"
        :key="index">
  <el-col :span="24" >
    医嘱内容:
    <span class="span" >
      {{item.get_advice.business_name}}
        </span>
         </el-col>
          <el-col :span="12">
             期效:
            <span class="span">
      {{item.get_advice.time_type==1?'长期':'短期'}}
        </span>
         </el-col>
          <el-col :span="12">
            医嘱医生:
       <span class="span" >
      {{item.get_advice.proofreader_name}}
        </span>
         </el-col>
          <el-col :span="12">
            类型:
        <span class="span" >
      {{  item.get_advice.status= item.get_advice.status==1?'西药':item.get_advice.status==2?
            '中药':item.get_advice.status==3?'检验':item.get_advice.status==4
            ?'检查':item.get_advice.status==5?'手术':'治疗'}}
        </span>
         </el-col>
          <el-col :span="12">
             执行护士:
         <span class="span">
     {{item.get_advice.stop_nurse_name}}
        </span>
         </el-col>
          <el-col :span="12">
            用法:
         <span class="span" >
      {{item.get_advice.usage}}
        </span>
         </el-col>
       
           <el-col :span="12">
             剂量:
       <span class="span" >
      {{item.get_advice.dose}}
        </span>
         </el-col>
            <el-col :span="12">
            频次:
        <span class="span" >
      {{item.get_advice.used_frqu.name}}
        </span>
         </el-col>
          <el-col :span="24">
            规格:
            <span class="span" >
      {{item.get_advice.specification}}
        </span>
         </el-col>
            <el-col :span="18">
       {{item.updated_at}}
         </el-col>
          <el-col :span="6">
            <el-link :underline="false" type="success" @click="seedelit(item)">查看详情</el-link>
         </el-col>
</el-card>
     <el-pagination
  background
  small
  layout="prev, pager, next"
  :current-page='currentPage'
  :page-size='pageSize'
  :total="totalPage"
  @prev-click='prevPage'
    @next-click='nextPage'
    v-if="currentPageData.length!=0"
  >
</el-pagination>
<el-dialog :close-on-click-modal='false'
  title="提示"
  :visible.sync="centerDialogVisible"
  width="70%"
  center
  class="see_box"
  :modal='false'
    v-if="tableData.lenght!=0"
  >
<el-col :span="8" >
    医嘱内容:
    <span class="span" >
      {{item.get_advice.business_name}}
        </span>
         </el-col>
          <el-col :span="8">
             期效:
            <span class="span">
      {{item.get_advice.time_type==1?'长期':'短期'}}
        </span>
         </el-col>
          <el-col :span="8">
            医嘱医生:
       <span class="span" >
      {{item.get_advice.proofreader_name}}
        </span>
         </el-col>
          <el-col :span="8">
            类型:
        <span class="span" >
      {{  item.get_advice.status= item.get_advice.status==1?'西药':item.get_advice.status==2?
            '中药':item.get_advice.status==3?'检验':item.get_advice.status==4
            ?'检查':item.get_advice.status==5?'手术':'治疗'}}
        </span>
         </el-col>
          <el-col :span="8">
             执行护士:
         <span class="span">
     {{item.get_advice.stop_nurse_name}}
        </span>
         </el-col>
          <el-col :span="8">
            用法:
         <span class="span" >
      {{item.get_advice.usage}}
        </span>
         </el-col>
       
           <el-col :span="8">
             剂量:
       <span class="span" >
      {{item.get_advice.dose}}
        </span>
         </el-col>
            <el-col :span="8">
            频次:
        <span class="span" >
      {{item.get_advice.used_frqu.name}}
        </span>
         </el-col>
         
          <el-col :span="8">
            数量:
        <span class="span" >
      {{item.get_advice.number}}
        </span>
         </el-col>
         <el-col :span="8">
            单价:
        <span class="span" >
      {{item.get_advice.price}}
        </span>
         </el-col>
              <el-col :span="8">
            金额:
        <span class="span" >
      {{item.get_advice.total}}
        </span>
         </el-col>
         
          <el-col :span="8">
            规格:
            <span class="span" >
      {{item.get_advice.specification}}
        </span>
         </el-col>
            <el-col :span="18">
               执行时间:
            <span class="span" >
           {{item.updated_at}}
        </span>

         </el-col>
  <span slot="footer" class="dialog-footer">
  
    <el-button type="success" @click="centerDialogVisible = false">确 定</el-button>
  </span>
</el-dialog>

<el-empty description="暂无数据"  v-if="currentPageData.length==0"></el-empty>
      </el-col>

</template>

<script>
import {
  getExecutionList,
} from "@/api/zhuyanre";

export default {
  // name:"costsRecord",
    props: ["id"],
  data(){
    return {
      tableData:[
     
      ],
      centerDialogVisible:false,
      item:{
        get_advice:{specification:'',
        total:'',price:'',number:'',
        used_frqu:{
          name:''
        },
        dose:'',
        stop_nurse_name:'',
        usage:'',
        business_name:'',
        proofreader_name:'',
        time_type:'',status:''}
      },
 //所有数据
              totalPage: 1, // 统共页数，默认为1
             currentPage: 1, //当前页数 ，默认为1
            pageSize: 4, // 每页显示数量
            currentPageData: [] //当前页显示内容
    
    }
    
  },
   mounted(){
       
      this.getExecutionList()
      //  this.totalPage = this.tableData.length ;
// 计算得0时设置为1
        this.totalPage = this.totalPage == 0 ? 1 : this.totalPage;
   },
   watch:{
      id(){
         this.getExecutionList()
         this.totalPage = this.totalPage == 0 ? 1 : this.totalPage;
      }
   },
   methods:{
     //查看  详情
     seedelit(item){
       console.log(item)
       this.item=item
       this.centerDialogVisible=true
     },
        getExecutionList() {
     let d = {
        hospital_id:this.id,
        status:''
      };

      getExecutionList(d).then((res) => {
         if(res.code==200){
           this.tableData=res.data.list
           if(this.tableData.length!=0){
        
           this.item=this.tableData[0]
           this.totalPage=res.data.count 
           this.totalPage = this.totalPage == 0 ? 1 : this.totalPage;
           let begin = (this.currentPage - 1) * this.pageSize;
                let end = this.currentPage * this.pageSize;
                this.currentPageData = this.tableData.slice(
                begin,
                end
                );
                     
           }
         }
      });
    },
        setCurrentPageData() {
                  let begin = (this.currentPage - 1) * this.pageSize;
                let end = this.currentPage * this.pageSize;
                this.currentPageData = this.tableData.slice(
                begin,
                end
                );
        },
//上一页
prevPage() {
        console.log(this.currentPage);
        if (this.currentPage == 1) return;

        this.currentPage--;
        this.setCurrentPageData();

},
// 下一页
nextPage() {
        if (this.currentPage == this.totalPage)return ;

        this.currentPage++;
        this.setCurrentPageData();

        }
 }

 
 
}
</script>

<style scoped>
.colmargin{
  overflow: auto ;

} 
.see_box .el-col{
  margin:5px 0px;
  font-size: 20px;
}
.see_box .span{
  color: dimgray;
  font-size: 18px;
  text-indent:2em;
}
 .span{
  color: dimgray;
  font-size: 13px;
  text-indent:2em;
}
.colmargin .el-col{
  margin:2px 0px;
}
</style>